<!DOCTYPE html>
<html>
<head>
<title>tester</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">
function getPath(){
      var str = document.getElementById('blaat').value;
      // lastIndexOf('\\') you need to use two \\'s because you use \ to escape
      str = str.substring(0, str.lastIndexOf('\\'));
      //if you want a closing \ just add a \ to the str (str += '\')
      document.getElementById('verborgenBlaat').value = str;
      // alert to proof it sets the directory
      alert(document.getElementById('verborgenBlaat').value)
}
</script>
</head>
<body>
   <form onsubmit="getPath();">
<input type="hidden" id="verborgenBlaat" value="" />
<input type="file" id="file" value="" />
<input type="submit">
<script>
 if ($.browser.msie) {
    $('#file').replaceWith($('#file').clone());
}
else {
    $('#file').val('');
} %>
</script>
</form>
</body>
</html>